/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 *
 * @author Hans
 */
public class MyDate {

    /**
     *
     * @param date date in format (dd-mm-yyyy)
     * @return milliseconds
     */
    public static long fromStringToLong(String date) {

        SimpleDateFormat f = new SimpleDateFormat("dd-mm-yyyy");
        Date d = null;
        try {
            d = f.parse(date);
        } catch (ParseException ex) {
            System.out.println("error parsing data. possibly faulty string input");
        }
        long milliseconds = 0;
        if (d != null) {
            d.getTime();
        }
        return milliseconds;
    }

    public static Date fromLongToDate(long date) {
        Date d = new Date(date);
        return d;
    }

    public static String fromLongToString(long date) {
        SimpleDateFormat f = new SimpleDateFormat("dd-mm-yyyy");
        Date d = new Date(date);
        return f.format(d);
    }

    private MyDate() {
    }
}
